<?php
/*
	author: dkloz
	Sends the password to its user's email
	
*/

function BL_sendPassword($username)
{

	
	$retval = BL_getIdfromUsername($username);


	if ($retval >= 0 ){
		$id = $retval;
		$user = BL_getUserData($id);
		return BL_send_lost_password($user);
		
	}

	else{
		return BL_GET_USER_DATA;
	}
}



function BL_send_lost_password($user)
{
	$to = $user->GetEmail();
 	$subject = "uCompare Password Retrieval";
 	$body = "Hello " . $user->GetName() . "\n\nIt seems that you forgot your password.\n";
 	$body = $body . "uCompare to the resque!\nYour data are:\n";
 	$body = $body . "Username: " . $user->GetUsername();
 	$body = $body . "\nPassword: " . $user->GetPassword();
 	$body = $body . "\n\n\nRegards,\n uCompare Administration";


 	if (mail($to, $subject, $body)) {
   		return BL_OK;
  	}
  	else {
   		return BL_MAIL_ERROR;
 	}
}
?>
